package cn.gson.fengboot.model.dao;

import cn.gson.fengboot.model.pojos.Lkefu;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface LkefuDao extends CrudRepository<Lkefu,Integer> {
    //圆形统计图类型分布查询
    @Query(nativeQuery = true,value = "SELECT count(*) FROM lkefu e  where e.kf_leixing =?1 and kf_zt =1")
    public Integer kflxcs(String Type);

    //圆形统计图服务方式分布查询
    @Query(nativeQuery = true,value = "SELECT count(*) FROM lkefu e  where e.kf_fangshi =?1 and kf_zt =1")
    public Integer khkefufscs(String Type);

    //圆形统计图服务状态分布查询
    @Query(nativeQuery = true,value = "SELECT count(*) FROM lkefu e  where e.kf_zhuangtai =?1 and kf_zt =1")
    public Integer khkefuztcs(String Type);

    //圆形统计图客服花费时间分布查询
    @Query(nativeQuery = true,value = "SELECT count(*) FROM lkefu e  where e.kf_huafeitime =?1 and kf_zt =1")
    public Integer khkefuhfsjcs(String Type);

    //圆形统计图服务次数分布查询
    @Query(nativeQuery = true,value = "SELECT count(*) FROM lkefu e LEFT JOIN tfyclient_form d  on e.client_id = d.client_id WHERE d.client_name =?1 and kf_zt =1")
    public Integer khkefufwcscs(String Type);

    //柱形统计图客服月度统计分布查询
    @Query(nativeQuery = true,value = "select count(*),kf_kaishitime from lkefu where month(kf_kaishitime) = month(kf_kaishitime) and  kf_zt=1 GROUP BY  year(kf_kaishitime) ORDER BY kf_kaishitime ASC")
    public List<Integer> ydkffb();

    //柱形统计图客服月度统计分布查询
    @Query(nativeQuery = true,value = "select kf_kaishitime from lkefu where kf_zt=1 GROUP BY year(kf_kaishitime) ORDER BY kf_kaishitime ASC")
    public  List<String> ydkffb1();


    //柱形统计图客户月度服务次数分布查询
    @Query(nativeQuery = true,value = "SELECT count(*),d.client_name FROM lkefu e LEFT JOIN tfyclient_form d  on e.client_id = d.client_id where d.client_name =?1")
    public  Integer khfwfb(String name);



}
